package com.klxedu.ms.gateway.core.json;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties({"data"})
public class JsonMapObject implements JsonObject<Map<String,Object>>,Map<String,Object>{

	private Map<String,Object> valueMap;

	public JsonMapObject() {
		this(new HashMap<>());
	}
	
	public JsonMapObject(Map<String,Object> valueMap) {
		this(valueMap,ResponesCode.SUCCESS);
	}
	
	public JsonMapObject(Map<String,Object> data,String valueMap) {
		this(data,valueMap,null);
	}
	
	public JsonMapObject(Map<String,Object> valueMap,String code,String message) {
		this.valueMap = valueMap;
		setData(valueMap);
		setCode(code);
		setMessage(message);
	}
	
	@Override
	public void clear() {
		valueMap.clear();
	}

	@Override
	public boolean containsKey(Object key) {
		return valueMap.containsKey(key);
	}

	@Override
	public boolean containsValue(Object value) {
		return valueMap.containsValue(value);
	}

	@Override
	public Set<Entry<String, Object>> entrySet() {
		return valueMap.entrySet();
	}

	@Override
	public Object get(Object key) {
		return valueMap.get(key);
	}

	@Override
	public boolean isEmpty() {
		return valueMap.isEmpty();
	}

	@Override
	public Set<String> keySet() {
		return valueMap.keySet();
	}

	@Override
	public Object put(String key, Object value) {
		return valueMap.put(key, value);
	}

	@Override
	public void putAll(Map<? extends String, ? extends Object> m) {
		valueMap.putAll(m);
	}

	@Override
	public Object remove(Object key) {
		return valueMap.remove(key);
	}

	@Override
	public int size() {
		return valueMap.size();
	}

	@Override
	public Collection<Object> values() {
		return valueMap.values();
	}

	@Override
	public void setData(Map<String,Object> data) {
		put("data",data);
	}

	@Override
	public void setCode(String code) {
		put("code",code);
	}

	@Override
	public void setMessage(String message) {
		put("message",message);
	}

	@Override
	public Map<String,Object> getData() {
		return valueMap;
	}

	@Override
	public String getCode() {
		return (String) get("code");
	}

	@Override
	public String getMessage() {
		return (String) get("message");
	}
	
}
